import type { LanguageResult } from "../types/api";
import http from "../utils/http";
import type {
  AirModelItem,
  AtaItem,
  CareerPlanningItem,
  CountryListItem,
  EngineItem,
  LMItem,
  LanguageItem,
  OnlineItem,
  SendEmailCode,
  SendPhoneCode,
  SexItem,
  UploadSingleImage,
} from "../types/global";
import type { HeaderNavItem } from "../types/banner";
import http2 from "../utils/http2";

// 获取当前语言
export const postSessionLanguage = () => {
  return http<LanguageResult>({
    url: "Member/lang",
    method: "POST",
  });
};

// 获取用的SESSIONID
export const postSessionId = () => {
  return http<any>({
    url: "member/session",
    method: "POST",
  });
};

// 语言设置
export const postChangeLanguage = (lang: string) => {
  return http2<LanguageResult>({
    url: "Index/set_lang",
    method: "POST",
    data: {
      lang,
    },
  });
};

// 全部在职状态
export const postOnlineAll = () => {
  return http<OnlineItem[]>({
    url: "Member/online",
    method: "POST",
  });
};
// 全部性别
export const postSexAll = () => {
  return http<SexItem[]>({
    url: "Member/sex",
    method: "POST",
  });
};
// 全部机型
export const postAriModelAll = (lang?: string) => {
  return http<AirModelItem[]>({
    // url: "AirModel/all",
    url: "AirModelPart6/all",
    method: "POST",
    data: {
      lang,
    },
  });
};
// 单图文件上传
export const postUploadSingleImg = (data: any) => {
  return http<any>({
    url: "Base/upload_one",
    method: "POST",
    data,
  });
};

// 发送手机验证码
export const postSendPhoneCode = (data: SendPhoneCode) => {
  return http<any>({
    url: "Member/captcha",
    method: "POST",
    data,
  });
};
// 个人技能-全部语言
export const postLanguageList = (lang?: string) => {
  return http<LanguageItem[]>({
    url: "Language/all",
    method: "POST",
    data: {
      lang,
    },
  });
};

// 发送邮箱验证码
export const postSendEmailCode = (data: SendEmailCode) => {
  return http<any>({
    url: "Member/email_captcha",
    method: "POST",
    data,
  });
};

// 全部国家
export const postAllContries = () => {
  return http<CountryListItem[]>({
    url: "Countries/country_az",
    method: "POST",
  });
};

// 头部导航栏
export const postHeaderNav = () => {
  return http<HeaderNavItem[]>({
    url: "BannerType/all",
    method: "POST",
  });
};

/**
 * 职业规划
 */
export const postAllDepartment = () => {
  return http<CareerPlanningItem[]>({
    url: "Department/all",
    method: "POST",
  });
};

export const postAllProfession = () => {
  return http<CareerPlanningItem[]>({
    url: "Profession/all",
    method: "POST",
  });
};

export const postAllStage = () => {
  return http<CareerPlanningItem[]>({
    url: "Stage/all",
    method: "POST",
  });
};

// 获取下载分类
export const postDownloadList = () => {
  return http<any>({
    url: "DownCategroy/index",
    method: "POST",
  });
};

// 单图文件上传
export const postDownloadFileList = (data: any) => {
  return http<any>({
    url: "Down/index",
    method: "POST",
    data,
  });
};

// ata全部数据
export const postAtaList = () => {
  return http<AtaItem[]>({
    url: "Ata/all",
    method: "POST",
  });
};

// engine_all
export const postEngineAll = () => {
  return http<EngineItem[]>({
    url: "MemberPart6/engine_all",
    method: "POST",
  });
};

// lm
export const postLmList = () => {
  return http<LMItem[]>({
    url: "Lm/all",
    method: "POST",
  });
};

// lm-apply
export const postLmSubmit = (data) => {
  return http<any>({
    url: "LmSubmit/create",
    method: "POST",
    data,
  });
};

// 课程申请声明
export const postAviationDetailApplyDeclare = () => {
  return http<{ id: number; title: string }[]>({
    url: "Options/all",
    method: "POST",
  });
};

/**
 *
 * 获取城市数据
 *
 */
export const postRecommendCity = () => {
  return http<{ id: number; title: string }[]>({
    url: "Countries/audit_city",
    method: "POST",
  });
};
export const postChinaCity = () => {
  return http<{ id: number; title: string }[]>({
    url: "Countries/china",
    method: "POST",
  });
};
export const postForeignCity = () => {
  return http<{ id: number; title: string }[]>({
    url: "Countries/foreign",
    method: "POST",
  });
};

// 所有国籍数据
// export const postNationalData = () => {
//   return http<{ id: number; title: string }[]>({
//     url: "CourseAddress/all.html?rand=6",
//     method: "POST",
//   });
// };
export const postNationalData = () => {
  return http<any[]>({
    url: "CourseAddress/all",
    method: "GET",
  });
};
